package com.ftg.learn.day11;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 通过hutool来操作execl
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/8/18 下午3:48
 */
public class JavaExclWithHuttool {

    public static void main(String[] args) {

        List<Higher> list = new ArrayList<>(5);

        ExcelReader reader = ExcelUtil.getReader("/home/kangjx/Desktop/abc.xlsx");
        List<Map<String, Object>> readAll = reader.readAll();

        System.out.println(readAll);

        for (int i = 0; i < readAll.size(); i++) {
            Map<String, Object> map = readAll.get(i);

            Higher h1 = new Higher();
            h1.setSno(Integer.valueOf(map.get("学号").toString()));
            h1.setName(map.get("姓名").toString());
            h1.setAge(Integer.valueOf(map.get("年龄").toString()));

            list.add(h1);

        }

        System.out.println(list);

    }

}
